package com.springboot.service;

import com.springboot.dao.ProductCategoryRepository;
import com.springboot.model.ProductCategory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {

    @Autowired
    private ProductCategoryRepository respository;

    @Override
    public ProductCategory findOne(Integer id) {

        return respository.findOne(id);
    }

    @Override
    @CachePut(value = "cai",key = "221")
    public void saveProductCategory(ProductCategory productCategory) {
        respository.save(productCategory);
    }

    @Override
    @Cacheable(value = "cai",key = "221")
    public List<ProductCategory> findAll() {

        return respository.findAll();
    }

    @Override
    public List<ProductCategory> findByCategoryTypeIn(List<Integer> list) {

        return respository.findByCategoryTypeIn(list);
    }
}
